package com.android.gardensnake;


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Typeface;
import android.view.View;

public class Player extends View {
	
	Bitmap gball;
	float changingY;
//	Typeface font;

	public Player(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		gball = BitmapFactory.decodeResource(getResources(), R.drawable.player);
		changingY = 600;
//		font = Typeface.createFromAsset(context.getAssets(), "comic.TTF");
	}

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		canvas.drawColor(Color.BLUE);
		
		Paint textPaint = new Paint();
		textPaint.setARGB(150, 255, 255, 250);
		textPaint.setTextAlign(Align.CENTER);
		textPaint.setTextSize(45);
//		textPaint.setTypeface(font);
		
		canvas.drawText("Space Battle", canvas.getWidth()/2, 200, textPaint);
		
//		Rect dreptunghi = new Rect();
//		dreptunghi.set(0, 400, canvas.getWidth(), 550);
//		Paint myBlue = new Paint();
//		myBlue.setColor(Color.BLUE);
//		canvas.drawRect(dreptunghi, myBlue);
		
		canvas.drawBitmap(gball, (canvas.getWidth()/2) , changingY, null);
		if (changingY < canvas.getHeight()){
			changingY -= 5;
			if(changingY == 0){
				changingY = 600;
			}
//		}else{
//			changingY = 600;
	}
		
		invalidate();
	}	

}
